package com.gitee.feizns.quickstart.ding.talk.api.v10.yida.processes.instances;

import com.aliyun.dingtalkyida_1_0.Client;
import com.aliyun.dingtalkyida_1_0.models.GetInstanceByIdHeaders;
import com.aliyun.dingtalkyida_1_0.models.GetInstanceByIdRequest;
import com.aliyun.dingtalkyida_1_0.models.GetInstanceByIdResponseBody;
import com.aliyun.teautil.models.RuntimeOptions;
import com.gitee.feizns.quickstart.ding.talk.client.Clients;
import lombok.SneakyThrows;

/**
 * 根据流程实例ID获取流程实例（/v2.0/yida/processes/instancesInfos/{id}）
 * 接口路径：<a href="https://open.dingtalk.com/document/orgapp/api-getinstancebyid-v2">根据流程实例ID获取流程实例（/v2.0/yida/processes/instancesInfos/{id}）</a>
 * @link <a href="https://open.dingtalk.com/document/orgapp/api-getinstancebyid-v2">服务端API 宜搭应用开发 流程 根据流程实例ID获取流程实例</a>
 * @author feizns
 * @since 2024/4/1
 */
public abstract class InstancesInfos {

    /**
     * 执行
     * @param accessToken 访问令牌
     * @param id 编号
     * @param request 请求
     * @return {@link GetInstanceByIdResponseBody}
     */
    @SneakyThrows
    public static GetInstanceByIdResponseBody execute(String accessToken, String id, GetInstanceByIdRequest request) {
        Client client = Clients.get(Client.class);
        GetInstanceByIdHeaders headers = headers(accessToken);;
        return client.getInstanceByIdWithOptions(id, request, headers, new RuntimeOptions()).body;
    }

    /**
     * 头
     * @param accessToken 访问令牌
     * @return {@link GetInstanceByIdHeaders}
     */
    public static GetInstanceByIdHeaders headers(String accessToken) {
        GetInstanceByIdHeaders headers = new GetInstanceByIdHeaders();
        headers.xAcsDingtalkAccessToken = accessToken;
        return headers;
    }

}
